/*
* Copyright (C) 2024-2025 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "schedulescanview.h"
#include "invokers/invokerfactory.h"
#include "gsettingkey.h"
#include "common.h"

//#include <DFontSizeManager>
//#include <DTitlebar>

#include <QComboBox>
#include <QRadioButton>

#define MAX_DAYS_IN_MONTH 31

ScheduleScanView::ScheduleScanView(QWidget *parent)
    : QFrame(parent)
    , m_monitorNetFlowInter(nullptr)
//    , m_blurEffect(nullptr)
    , m_setupItemNew(new ScheduleScanItem(this))
    , m_pTypeButtonGrop(new QButtonGroup(this))
    , m_quickButton(nullptr)
    , m_fullButton(nullptr)
    , m_pFoundButtonGrop(new QButtonGroup(this))
    , m_askButton(nullptr)
    , m_autoButton(nullptr)
    , m_timeSpanCombobox(nullptr)
    , m_dayOfMonthMultiComboBox(nullptr)
    , m_dayOfWeekMultiComboBox(nullptr)
    , m_dateEdit(nullptr)
    , m_timeEdit(nullptr)
    , m_contentWidget(nullptr)
    , m_gsetting(nullptr)
    , m_timerScanSwitch(false)
    , m_timerScanType(false)
    , m_timerScanHandle(false)

{
    // 初始化安全中心gsetting配置
    m_gsetting = InvokerFactory::GetInstance().CreateSettings("com.deepin.dde.deepin-defender", QByteArray(), this);
    // 系统服务
    m_monitorNetFlowInter = InvokerFactory::GetInstance().CreateInvoker("com.deepin.defender.MonitorNetFlow",
                                                                        "/com/deepin/defender/MonitorNetFlow",
                                                                        "com.deepin.defender.MonitorNetFlow",
                                                                        ConnectType::SYSTEM, this);

    // 初始化界面
    initUI();
    // 初始化数据
    initData();
}

void ScheduleScanView::initUI()
{
    // 主布局
    QVBoxLayout *mainlayout = new QVBoxLayout(this);
    mainlayout->setContentsMargins(0, 0, 0, 0);
    mainlayout->setSpacing(0);
    mainlayout->setAlignment(Qt::AlignmentFlag::AlignTop);

    // 加入定时扫描设置选项
    m_setupItemNew->setText(tr("Schedule a scan"));
    m_setupItemNew->setSwitchStatus(false);
    mainlayout->addWidget(m_setupItemNew);

    // 加入一个布局  将主要控制内容放置其中，按钮控制显示/隐藏
    m_contentWidget = new QWidget(this);
    QVBoxLayout *contentLayout = new QVBoxLayout;
    contentLayout->setContentsMargins(0, 0, 0, 0);
    contentLayout->setSpacing(0);

    /****************扫描类型单选***************/

    // 加入定时扫描设置名称
    contentLayout->addSpacing(20);
    QLabel *lbScanTypeName = new QLabel(this);
    lbScanTypeName->setText(tr("Scan type"));
    lbScanTypeName->setContentsMargins(0, 0, 0, 0);
    QFont ft;
    lbScanTypeName->setFont(ft);
//    DFontSizeManager::instance()->bind(lbScanTypeName, DFontSizeManager::T7);
    contentLayout->addWidget(lbScanTypeName, 0, Qt::AlignLeft);

    //单选按钮组
    contentLayout->addSpacing(10);
    QVBoxLayout *pLayout = new QVBoxLayout();
    pLayout->setContentsMargins(0, 0, 0, 0);
    m_pTypeButtonGrop->setExclusive(true);

    //快速扫描按钮
    m_quickButton = new QRadioButton(this);
    m_quickButton->setText(tr("Quick scan"));
//    DFontSizeManager::instance()->bind(m_quickButton, DFontSizeManager::T7);
    pLayout->addWidget(m_quickButton);
    m_pTypeButtonGrop->addButton(m_quickButton);

    //全盘扫描按钮
    m_fullButton = new QRadioButton(this);
    m_fullButton->setText(tr("Full scan"));
//    DFontSizeManager::instance()->bind(m_fullButton, DFontSizeManager::T7);
    pLayout->addWidget(m_fullButton);
    m_pTypeButtonGrop->addButton(m_fullButton);

    contentLayout->addLayout(pLayout);

    /****************扫描时间设置***************/

    // 加入定时扫描设置名称
    contentLayout->addSpacing(20);
    QLabel *lbScanTimeName = new QLabel(this);
    lbScanTimeName->setText(tr("Scan time"));
    lbScanTimeName->setContentsMargins(0, 0, 0, 0);
    lbScanTimeName->setFont(ft);
//    DFontSizeManager::instance()->bind(lbScanTimeName, DFontSizeManager::T7);
    contentLayout->addWidget(lbScanTimeName, 0, Qt::AlignLeft);

    // 下拉选择框1
    contentLayout->addSpacing(10);
    QHBoxLayout *comboboxLayout = new QHBoxLayout();

    m_timeSpanCombobox = new QComboBox(this);
    m_timeSpanCombobox->setFixedSize(QSize(130, 36));
    m_timeSpanCombobox->addItem(tr("Every day"));
    m_timeSpanCombobox->addItem(tr("Every week"));
    m_timeSpanCombobox->addItem(tr("Every month"));
    m_timeSpanCombobox->addItem(tr("Customize"));

    // 下拉选择框2
    // 垂直布局
    QVBoxLayout *twoLayout = new QVBoxLayout();

    m_dayOfWeekMultiComboBox = new MultiComBox(this);
    m_dayOfMonthMultiComboBox = new MultiComBox(this);
    m_dateEdit = new QDateEdit(this);

    m_dayOfWeekMultiComboBox->setFixedSize(QSize(130, 36));
    m_dayOfMonthMultiComboBox->setFixedSize(QSize(130, 36));
    m_dateEdit->setFixedSize(QSize(140, 36));

    twoLayout->addStrut(0);
    twoLayout->addWidget(m_dayOfWeekMultiComboBox);
    twoLayout->addWidget(m_dayOfMonthMultiComboBox);
    twoLayout->addWidget(m_dateEdit);

    m_dayOfWeekMultiComboBox->setVisible(false);
    m_dayOfMonthMultiComboBox->setVisible(false);
    m_dateEdit->setVisible(false);

    // 选项1: timeEdit 时间编辑器默认由横向第三个时间编辑器控件展示

    // 选项2: week 周一至周日
    // 下拉框 new MultiComBox
    QList<MenuItem *> listWeekMenuitem;
    QStringList list_week = {tr("Monday"),
                             tr("Tuesday"),
                             tr("Wednesday"),
                             tr("Thursday"),
                             tr("Friday"),
                             tr("Saturday"),
                             tr("Sunday")};

    for (int i = 0; i < list_week.size(); i++) {
        MenuItem *wMenuitem = new MenuItem(i, list_week[i], false);
        listWeekMenuitem.append(wMenuitem);
    }
    m_dayOfWeekMultiComboBox->addItems(listWeekMenuitem);

    // 选项3: month 1-31
    // 下拉框 new MultiComBox
    QList<MenuItem *> listMenuitem;
    for (int i = 0; i < MAX_DAYS_IN_MONTH; i++) {
        MenuItem *pMenuitem = new MenuItem(i, QString::number(i + 1), false);
        listMenuitem.append(pMenuitem);
    }

    m_dayOfMonthMultiComboBox->addItems(listMenuitem);

    // 选项4: dateEdit 日期选择框
    m_dateEdit->setDisplayFormat("yyyy/MM/dd"); // 设置日期显示格式
    m_dateEdit->setCalendarPopup(true); // 设置显示日历弹窗
    m_dateEdit->setDateTime(QDateTime::currentDateTime()); // 设置日期时间
    m_dateEdit->setProperty("_d_dtk_spinBox", 1);

    // 时间编辑器3
    m_timeEdit = new QTimeEdit(this);
    m_timeEdit->setProperty("_d_dtk_spinBox", 1); // 设置时间编辑器按钮样式
    m_timeEdit->setFixedSize(QSize(130, 36));
    m_timeEdit->setDisplayFormat("HH:mm");

    // 扫描时间整体设置 横向布局
    comboboxLayout->addWidget(m_timeSpanCombobox, 0, Qt::AlignLeft);
    comboboxLayout->addSpacing(10);
    comboboxLayout->addLayout(twoLayout);
    comboboxLayout->addSpacing(10);
    comboboxLayout->addWidget(m_timeEdit, 0, Qt::AlignLeft);
    comboboxLayout->addStretch();

    contentLayout->addLayout(comboboxLayout);

    /****************发现病毒处理方式设置***************/

    // 加入发现病毒处理方式名称
    contentLayout->addSpacing(20);
    QLabel *lbFoundName = new QLabel(this);
    lbFoundName->setText(tr("When viruses are found"));
    lbFoundName->setContentsMargins(0, 0, 0, 0);
    lbFoundName->setFont(ft);
//    DFontSizeManager::instance()->bind(lbFoundName, DFontSizeManager::T7);
    contentLayout->addWidget(lbFoundName, 0, Qt::AlignLeft);

    // 单选按钮组
    contentLayout->addSpacing(10);
    QVBoxLayout *fLayout = new QVBoxLayout();
    fLayout->setContentsMargins(0, 0, 0, 0);
    m_pFoundButtonGrop->setExclusive(true);

    // 询问按钮
    m_askButton = new QRadioButton(this);
    m_askButton->setText(tr("Ask me"));
//    DFontSizeManager::instance()->bind(m_askButton, DFontSizeManager::T7);
    fLayout->addWidget(m_askButton);
    m_pFoundButtonGrop->addButton(m_askButton);

    // 自动处理按钮
    m_autoButton = new QRadioButton(this);
    m_autoButton->setText(tr("Auto remove"));
//    DFontSizeManager::instance()->bind(m_autoButton, DFontSizeManager::T7);
    fLayout->addWidget(m_autoButton);
    m_pFoundButtonGrop->addButton(m_autoButton);

    contentLayout->addLayout(fLayout);

    m_contentWidget->setLayout(contentLayout);
    mainlayout->addWidget(m_contentWidget);

    //    contentWidget->setVisible(false);
}

// 初始化数据
void ScheduleScanView::ScheduleScanView::initData()
{
    // 设置默认时间
    m_defaultTime = QTime::fromString("17:00", "HH:mm");

    // 初始化总开关·
    m_timerScanSwitch = m_gsetting->GetValue(TIMER_SCAN_SWITCH).toBool();
    m_setupItemNew->setSwitchStatus(m_timerScanSwitch);
    setWidgetStatus(m_timerScanSwitch);
    connect(m_setupItemNew, SIGNAL(switchTrigger()), this, SLOT(acceptTimerScanSwitchStatusChange()));

    // 初始化扫描类型
    m_timerScanType = m_gsetting->GetValue(TIMER_SCAN_TYPE).toBool();
    if (m_timerScanType) {
        m_fullButton->setChecked(true);
    } else {
        m_quickButton->setChecked(true);
    }
    // 扫描时间点选择
    m_sScanTime = m_gsetting->GetValue(TIMER_SCAN_TIME).toString();

    // 根据存储的时间点显示控件
    QStringList sStr = m_sScanTime.split("|");
    if (sStr.count() >= 3) {
        int nType = sStr.at(0).toInt();
        QString sDate = sStr.at(1);
        QString sTime = sStr.at(2);
        QStringList sDateList = sDate.split(";");

        m_timeSpanCombobox->setCurrentIndex(nType);
        m_timeEdit->setTime(QTime::fromString(sTime, "HH:mm"));

        if (ScheduleScanTimeType::Everyday == nType) {
            m_dayOfWeekMultiComboBox->setVisible(false);
            m_dayOfMonthMultiComboBox->setVisible(false);
            m_dateEdit->setVisible(false);
            m_timeEdit->setTime(QTime::fromString(sTime, "HH:mm"));
        } else if (ScheduleScanTimeType::Everyweek == nType) {
            m_dayOfWeekMultiComboBox->setVisible(true);
            m_dayOfMonthMultiComboBox->setVisible(false);
            m_dateEdit->setVisible(false);
            for (int i = 0; i < sDateList.count(); ++i) {
                m_dayOfWeekMultiComboBox->setActivated(sDateList.at(i).toInt());
            }
        } else if (ScheduleScanTimeType::Everymonth == nType) {
            m_dayOfWeekMultiComboBox->setVisible(false);
            m_dayOfMonthMultiComboBox->setVisible(true);
            m_dateEdit->setVisible(false);
            for (int i = 0; i < sDateList.count(); ++i) {
                m_dayOfMonthMultiComboBox->setActivated(sDateList.at(i).toInt());
            }
        } else {
            m_dayOfWeekMultiComboBox->setVisible(false);
            m_dayOfMonthMultiComboBox->setVisible(false);
            m_dateEdit->setVisible(true);
            m_dateEdit->setDateTime(QDateTime::fromString(sDate, "yyyy/MM/dd"));
        }

    } else {
        m_dayOfWeekMultiComboBox->setVisible(true);
        m_dayOfMonthMultiComboBox->setVisible(false);
        m_dateEdit->setVisible(false);
        m_timeSpanCombobox->setCurrentIndex(ScheduleScanTimeType::Everyweek);
        m_dayOfWeekMultiComboBox->setActivated(0);
        m_timeEdit->setTime(m_defaultTime);

        setTimeGsetting();
    }

    // 初始化时间点各控件文本改变信号槽
    connect(m_timeSpanCombobox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(onAppOneChanged(const QString &)));
    // 更改时间跨度 增加安全日志记录
    connect(m_timeSpanCombobox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(addDayInEveryWeekOrMonthLog(const QString &)));

    connect(m_timeEdit, SIGNAL(timeChanged(const QTime &)), this, SLOT(addTimeChangeLog(const QTime &)));

    connect(m_dayOfWeekMultiComboBox, SIGNAL(currentTextChanged()), this, SLOT(onCurrentTextChangedOfMultiComboBox()));
    connect(m_dayOfMonthMultiComboBox, SIGNAL(currentTextChanged()), this, SLOT(onCurrentTextChangedOfMultiComboBox()));
    connect(m_dateEdit, SIGNAL(dateChanged()), this, SLOT(onDateChanged()));

    // 每周、每月选项 日志添加
    connect(m_dayOfWeekMultiComboBox, SIGNAL(sendSelected(QList<int>)), this, SLOT(addDayInEveryWeekOrMonthLog(QList<int>)));
    connect(m_dayOfMonthMultiComboBox, SIGNAL(sendSelected(QList<int>)), this, SLOT(addDayInEveryWeekOrMonthLog()));

    // 初始化处理方式
    m_timerScanHandle = m_gsetting->GetValue(TIMER_SCAN_HANDLE).toBool();
    if (m_timerScanHandle) {
        m_autoButton->setChecked(true);
    } else {
        m_askButton->setChecked(true);
    }
    connect(m_askButton, SIGNAL(clicked()), this, SLOT(acceptTimerAskHandleClicked()));
    connect(m_autoButton, SIGNAL(clicked()), this, SLOT(acceptTimerAutoHandleClicked()));
}

void ScheduleScanView::onAppOneChanged(int index)
{
    // 阻塞时间编辑框信号
    m_timeEdit->blockSignals(true);

    if (ScheduleScanTimeType::Everyday == index) {
        m_dayOfWeekMultiComboBox->setVisible(false);
        m_dayOfMonthMultiComboBox->setVisible(false);
        m_dateEdit->setVisible(false);
        m_dayOfWeekMultiComboBox->setActivated(0);
        m_timeEdit->setTime(m_defaultTime);

    } else if (ScheduleScanTimeType::Everyweek == index) {
        m_dayOfWeekMultiComboBox->setVisible(true);
        m_dayOfMonthMultiComboBox->setVisible(false);
        m_dateEdit->setVisible(false);
        m_dayOfWeekMultiComboBox->setActivated(0);
        m_timeEdit->setTime(m_defaultTime);

    } else if (ScheduleScanTimeType::Everymonth == index) {
        m_dayOfWeekMultiComboBox->setVisible(false);
        m_dayOfMonthMultiComboBox->setVisible(true);
        m_dateEdit->setVisible(false);
        m_dayOfMonthMultiComboBox->setActivated(0);
        m_timeEdit->setTime(m_defaultTime);

    } else if (ScheduleScanTimeType::CustomizeType == index) {
        m_dayOfWeekMultiComboBox->setVisible(false);
        m_dayOfMonthMultiComboBox->setVisible(false);
        m_dateEdit->setVisible(true);
        m_dateEdit->setDateTime(QDateTime::currentDateTime());
        m_timeEdit->setTime(m_defaultTime);
    }

    // 解除信号阻塞
    m_timeEdit->blockSignals(false);

    setTimeGsetting();
}

// 定时扫描总开关状态改变槽
void ScheduleScanView::acceptTimerScanSwitchStatusChange()
{
    if (m_setupItemNew->getSwitchStatus() != m_gsetting->GetValue(TIMER_SCAN_SWITCH).toBool()) {
        // 状态取反
        bool isbStatus = !m_gsetting->GetValue(TIMER_SCAN_SWITCH).toBool();
        //setTimerUi(isbStatus);
        Q_EMIT sendSwitchChanged(isbStatus);
    }
}

// 设置状态
void ScheduleScanView::setTimerUi(bool isStatus)
{
    m_gsetting->SetValue(TIMER_SCAN_SWITCH, isStatus);
    m_setupItemNew->setSwitchStatus(isStatus);
    setWidgetStatus(isStatus);

    // 日志添加
    isStatus == true ? DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, tr("Schedule scans: ON") + ", " + getLogStr())
                     : DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, tr("Schedule scans: OFF") + ", " + getLogStr());
}

// 根据开关状态置灰/置亮空间
void ScheduleScanView::setWidgetStatus(bool bStatus)
{
    m_contentWidget->setVisible(bStatus);
}

// 定时快速扫描总类型改变槽
void ScheduleScanView::acceptTimerQuickScanTypeClicked()
{
    m_gsetting->SetValue(TIMER_SCAN_TYPE, 0);
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}
// 定时全盘扫描总类型改变槽
void ScheduleScanView::acceptTimerFullScanTypeClicked()
{
    m_gsetting->SetValue(TIMER_SCAN_TYPE, 1);
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}

// 定时扫描询问处理方式改变槽
void ScheduleScanView::acceptTimerAskHandleClicked()
{
    m_gsetting->SetValue(TIMER_SCAN_HANDLE, 0);
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}
// 定时扫描自动处理方式改变槽
void ScheduleScanView::acceptTimerAutoHandleClicked()
{
    m_gsetting->SetValue(TIMER_SCAN_HANDLE, 1);
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}

void ScheduleScanView::addDayInEveryWeekOrMonthLog()
{
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}

void ScheduleScanView::addTimeChangeLog()
{
    //日志
    setTimeGsetting();
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}

void ScheduleScanView::onCurrentTextChangedOfMultiComboBox()
{
    setTimeGsetting();
}

void ScheduleScanView::onDateChanged()
{
    setTimeGsetting();
    // 日志
    DBUS_BLOCK_INVOKE(m_monitorNetFlowInter, "AddSecurityLog", SECURITY_LOG_TYPE_ANTIAV, getLogStr());
}

// 定时时间gsetting设置
void ScheduleScanView::setTimeGsetting()
{
    int nType = m_timeSpanCombobox->currentIndex();
    // 将扫描时间点组合成字符串，存储到gsetting
    QString sSaveTimeStr;

    if (ScheduleScanTimeType::Everyday == nType) {
        sSaveTimeStr = QString("%1|%2|%3").arg(m_timeSpanCombobox->currentIndex()).arg("").arg(m_timeEdit->text());
    } else if (ScheduleScanTimeType::Everyweek == nType) {
        sSaveTimeStr = QString("%1|%2|%3").arg(m_timeSpanCombobox->currentIndex()).arg(m_dayOfWeekMultiComboBox->getSelectedRows()).arg(m_timeEdit->text());
    } else if (ScheduleScanTimeType::Everymonth == nType) {
        sSaveTimeStr = QString("%1|%2|%3").arg(m_timeSpanCombobox->currentIndex()).arg(m_dayOfMonthMultiComboBox->getSelectedRows()).arg(m_timeEdit->text());
    } else if (ScheduleScanTimeType::CustomizeType == nType) {
        sSaveTimeStr = QString("%1|%2|%3").arg(m_timeSpanCombobox->currentIndex()).arg(m_dateEdit->dateTime().toString("yyyy/MM/dd")).arg(m_timeEdit->text());
    }

    m_gsetting->SetValue(TIMER_SCAN_TIME, sSaveTimeStr);
}

QString ScheduleScanView::getLogStr()
{
    QString sLogScanType;
    QString sLogScanHandle;

    sLogScanType = (m_gsetting->GetValue(TIMER_SCAN_TYPE) == 0) ? tr("Schedule scans") + ", " + tr("Scan type: Quick scan") : tr("Schedule scans") + ", " + tr("Scan type:  Full scan"); // 定时扫描类型
    sLogScanHandle = (m_gsetting->GetValue(TIMER_SCAN_HANDLE) == 0) ? tr("When viruses are found: Ask me") : tr("When viruses are found: Auto remove"); // 处理方式类型

    QString sLogTimeStr;
    int nType = m_timeSpanCombobox->currentIndex();

    if (ScheduleScanTimeType::Everyday == nType) {
        sLogTimeStr = tr("Scan time: %1, %2").arg(m_timeSpanCombobox->currentText()).arg(m_timeEdit->text());
    } else if (ScheduleScanTimeType::Everyweek == nType) {
        sLogTimeStr = tr("Scan time: Every week %1, %2").arg(selectWeeksHandle()).arg(m_timeEdit->text());
    } else if (ScheduleScanTimeType::Everymonth == nType) {
        sLogTimeStr = tr("Scan time: Every month %1, %2").arg(selectMonthsHandle()).arg(m_timeEdit->text());
    } else if (ScheduleScanTimeType::CustomizeType == nType) {
        sLogTimeStr = tr("Scan time: %1, %2").arg(m_dateEdit->dateTime().toString("yyyy/MM/dd")).arg(m_timeEdit->text());
    }
    QString sLogScanSetting = QString("%1, %2, %3").arg(sLogScanType).arg(sLogTimeStr).arg(sLogScanHandle);
    return sLogScanSetting;
}

QString ScheduleScanView::selectWeeksHandle()
{
    QStringList listWeekSeleted;
    QStringList listDayofWeekShow;

    listWeekSeleted = m_dayOfWeekMultiComboBox->getItemsText();

    // 将每周日期取出
    for (int i = 0; i < listWeekSeleted.count(); i++) {
        QString week = listWeekSeleted.at(i);
        listDayofWeekShow << week;
    }
    QString sAllWeekSeleted = listDayofWeekShow.join(", ");
    return sAllWeekSeleted;
}

QString ScheduleScanView::selectMonthsHandle()
{
    QStringList listMonthSeleted;
    QStringList listDayofMonthShow;

    listMonthSeleted = m_dayOfMonthMultiComboBox->getItemsText();

    // 将每月日期取出
    for (int i = 0; i < listMonthSeleted.count(); i++) {
        int month = listMonthSeleted.at(i).toInt();
        listDayofMonthShow << QString::number(month);
    }
    QString sAllMonthSeleted = listDayofMonthShow.join(", ");
    return sAllMonthSeleted;
}
